New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

graphql-playground-html

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-playground-html

GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).


Version published
Weekly downloads
306K
increased by5.97%
Maintainers
6
Weekly downloads
 
Created

What is graphql-playground-html?

The graphql-playground-html npm package provides a way to embed GraphQL Playground, a powerful GraphQL IDE, into your web applications. It allows developers to interact with their GraphQL APIs through a user-friendly interface, making it easier to test queries, mutations, and subscriptions.

What are graphql-playground-html's main functionalities?

Embedding GraphQL Playground

This code sample demonstrates how to embed GraphQL Playground into an HTML page. It includes the necessary CSS and JavaScript files from a CDN and initializes the playground with a specified GraphQL endpoint.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>GraphQL Playground</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/graphql-playground-html@latest/build/static/css/index.css" />
    <link rel="shortcut icon" href="https://cdn.jsdelivr.net/npm/graphql-playground-html@latest/build/favicon.png" />
    <script src="https://cdn.jsdelivr.net/npm/graphql-playground-html@latest/build/static/js/middleware.js"></script>
  </head>
  <body>
    <div id="root"></div>
    <script>
      window.addEventListener('load', function (event) {
        GraphQLPlayground.init(document.getElementById('root'), { endpoint: '/graphql' })
      })
    </script>
  </body>
</html>

Customizing GraphQL Playground

This code sample shows how to customize the GraphQL Playground by setting various options such as the editor theme and cursor shape. These settings can be adjusted to fit the developer's preferences.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>GraphQL Playground</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/graphql-playground-html@latest/build/static/css/index.css" />
    <link rel="shortcut icon" href="https://cdn.jsdelivr.net/npm/graphql-playground-html@latest/build/favicon.png" />
    <script src="https://cdn.jsdelivr.net/npm/graphql-playground-html@latest/build/static/js/middleware.js"></script>
  </head>
  <body>
    <div id="root"></div>
    <script>
      window.addEventListener('load', function (event) {
        GraphQLPlayground.init(document.getElementById('root'), {
          endpoint: '/graphql',
          settings: {
            'editor.theme': 'dark',
            'editor.cursorShape': 'line'
          }
        })
      })
    </script>
  </body>
</html>

Other packages similar to graphql-playground-html

FAQs

Package last updated on 04 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts